package fr.gdi.android.news.utils;

import java.io.IOException;
import java.io.OutputStream;

public class StringOutputStream extends OutputStream
{
    
    private StringBuilder buffer;
    
    public StringOutputStream()
    {
        buffer = new StringBuilder();
    }
    
    @Override
    public void write(int data) throws IOException
    {
        buffer.append((char) data);
    }
    
    @Override
    public void write(byte[] bytes, int offset, int count) throws IOException
    {
        for (int u = offset; u < count; u++)
        {
            buffer.append(bytes[u]);
        }
    }
    
    @Override
    public void write(byte[] bytes) throws IOException
    {
        buffer.append(bytes);
    }
    
    public String toString()
    {
        return buffer.toString();
    }
}
